package com.opc.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.opc.dto.DeviceRecordTimesDto;
import com.opc.dto.HistoryRecordDto;
import com.opc.entity.DeviceRecord;
import com.opc.entity.PageRes;
import com.opc.excel.HistoryExcel;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 服务类
 * </p>
 *
 * @author 作者
 * @since 2023-03-14
 */
public interface DeviceRecordService extends IService<DeviceRecord> {

    DeviceRecord selectLatestRecordByDcAndType(String deviceCode, Integer type);

    int updateDeviceRecordByCodesAndType(List<String> uIdList, int type);

    List<DeviceRecord> selectAllRecordListByIds(List<String> dList, Date searchTime);

    int updateDeviceRecordByIds(List<Long> uIdList);

    List<DeviceRecord> selectConsumeByProLine(Date startTime, Date endTime, String proLine);

    /**
     * 查找设备的更换次数
     *
     * @param startTime
     * @param currentDate
     * @return
     */
    List<DeviceRecordTimesDto> selectConsumeByProLineNew(Date startTime, Date currentDate, Integer offset);

    /**
     * 获取产线设备的消耗和异常记录 当查询异常消耗记录时，recordType=1
     *
     * @param proLine
     * @param startTime
     * @param endTime
     * @param valType
     * @param recordType
     * @return
     */
    PageRes<HistoryRecordDto> getAbnormalHistory(String proLine, String startTime, String endTime, String valType, String recordType, Integer pageNo, Integer pageSize);

    /**
     * 获取历史消耗记录
     *
     * @param proLine
     * @param startTime
     * @param endTime
     * @param valType
     * @param recordType
     * @param pageNo
     * @param pageSize
     * @return
     */
    PageRes<HistoryRecordDto> getHistoryList(String proLine, String startTime, String endTime, String valType, String recordType, Integer pageNo, Integer pageSize);

    /**
     * 导出
     *
     * @param proLine
     * @param startTime
     * @param endTime
     * @param valType
     * @param recordType
     */
    List<HistoryExcel> getHistoryListExcel(String proLine, String startTime, String endTime, String valType, String recordType);

    List<HistoryRecordDto> getAbnormalHistoryExcel(String proLine, String startTime, String endTime, String valType, String recordType);

    int delAbnormal(Long[] recordIds);
}
